import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;

public class ExcelOpe {
    public static void main(String[] args) {
//        Workbook wb = new XSSFWorkbook();
        try {

            String filePath = "C:\\Users\\Synyi\\Downloads\\知识图谱schema模版.xlsx";
            File file = new File(filePath);
            if (file.exists()) {
                file.delete();
            }
            OutputStream fileOutputStream = new FileOutputStream(file);
            Workbook wb = new XSSFWorkbook();
            Sheet sheet = wb.createSheet("定义");
            Row row = sheet.createRow(0);
            row.createCell(0).setCellValue("ID");
            row.createCell(1).setCellValue("类型");
            row.createCell(2).setCellValue("名称");
            row.createCell(3).setCellValue("定义");
            int i = 1;
            while (i < 200000) {
                row = sheet.createRow(i);
                //定义
                String id = "test" + i;
                row.createCell(0).setCellValue(id);
                //类型
                row.createCell(1).setCellValue("语义类型");
                //名称
                String name = "测试class" + i;
                row.createCell(2).setCellValue(name);
                //定义
                row.createCell(3).setCellValue(name);
                i++;
            }
            wb.write(fileOutputStream);
            wb.close();
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
